package com.grad.webstudy.controller;

import com.grad.webstudy.annota.LoginAuthorization;
import com.grad.webstudy.model.Code;
import com.grad.webstudy.service.CodeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Description:
 * @Author: zjf
 * @Date: 2020/1/15 11:45.
 */
@RestController
@RequestMapping("/code")
public class CodeController {

    @Autowired
    private CodeService codeService;

    @PostMapping("/run")
    public String runCode(@RequestBody Code code) {
        return codeService.runCode(code);
    }


    @GetMapping("/query")
    @LoginAuthorization
    public List<Code> queryCodes() {
        return codeService.findCode();
    }

}
